<template>
  <div>
    <div>
      <Breadcrumb />
    </div>
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="商品id">
        <el-input v-model="form.goods_id"></el-input>
      </el-form-item>
      <el-form-item label="图片上传">
        <el-upload
          action="http://web.woniulab.com:8005/admin/fileUpload"
          :on-success="handleAvatarSuccess"
          name=imgSrc
          list-type="picture-card"
          :headers="headers"
          
          :on-preview="handlePictureCardPreview"
          :on-remove="handleRemove"
        >
          <i class="el-icon-plus"></i>
        </el-upload>
      </el-form-item>
        <el-form-item label="跳转方式">
        <el-input v-model="form.open_type"></el-input>
      </el-form-item>
 <el-form-item label="跳转页面">
        <el-input v-model="form.navigator_url"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">立即创建</el-button>
        <el-button>取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import Breadcrumb from "../../commponents/common/Breadcrumb.vue";
export default {
  components: { Breadcrumb },
  data() {
    return {
      form: {
        goods_id: "",
        navigator_url:"",
        image_src:'',
        open_type:''
      },
      dialogImageUrl: "",
      dialogVisible: false,
      img:"",
     
      
    };
  },
  methods: {
  async  onSubmit() {
      const{ data} = await this.$api.carousel.addSwiper({...this.form});
      console.log(data);
      if(data.code==200){
        alert('注册成功')
      }
      
    },
    //重置按钮
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
    },
    handleAvatarSuccess(res, file) {
      this.form.image_src='http://web.woniulab.com:8005/images/'+res.data;
      //   this.formLabelAlign.image='http://47.98.128.191:3000/'+res.data[0];
    },
  },
  computed:{
    headers(){
      return{
        "Authorization":localStorage.token
      }
    }
  }
};
</script>

<style scoped>
</style>>

